package cn.b504.qpcr.controller;

import cn.b504.qpcr.entity.AjaxResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.nio.charset.StandardCharsets;

@RestController
@RequestMapping("/uploadAction")
public class UploadController {

  @RequestMapping("/upload")
  public AjaxResult upload(MultipartFile file) throws IOException {
    byte[] bytes = file.getBytes();
    String res = new String(bytes, StandardCharsets.UTF_8);
    return AjaxResult.ok(res, file.getOriginalFilename() + " 上传成功");
  }
}
